.class public Lorg/microemu/android/device/AndroidFontManager;
.super Ljava/lang/Object;
.source "AndroidFontManager.java"

# interfaces
.implements Lorg/microemu/device/FontManager;


# static fields
.field private static SIZE_LARGE:I

.field private static SIZE_MEDIUM:I

.field private static SIZE_SMALL:I

.field private static fonts:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljavax/microedition/lcdui/Font;",
            "Lorg/microemu/android/device/AndroidFont;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 39
    const/16 v0, 0xc

    sput v0, Lorg/microemu/android/device/AndroidFontManager;->SIZE_SMALL:I

    .line 40
    const/16 v0, 0x10

    sput v0, Lorg/microemu/android/device/AndroidFontManager;->SIZE_MEDIUM:I

    .line 41
    const/16 v0, 0x14

    sput v0, Lorg/microemu/android/device/AndroidFontManager;->SIZE_LARGE:I

    .line 43
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    sput-object v0, Lorg/microemu/android/device/AndroidFontManager;->fonts:Ljava/util/HashMap;

    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 37
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static getFont(Ljavax/microedition/lcdui/Font;)Lorg/microemu/android/device/AndroidFont;
    .locals 7
    .parameter "meFont"

    .prologue
    .line 47
    sget-object v5, Lorg/microemu/android/device/AndroidFontManager;->fonts:Ljava/util/HashMap;

    invoke-virtual {v5, p0}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lorg/microemu/android/device/AndroidFont;

    .line 49
    .local v1, result:Lorg/microemu/android/device/AndroidFont;
    if-nez v1, :cond_6

    .line 50
    sget-object v0, Landroid/graphics/Typeface;->SANS_SERIF:Landroid/graphics/Typeface;

    .line 51
    .local v0, family:Landroid/graphics/Typeface;
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getFace()I

    move-result v5

    if-nez v5, :cond_7

    .line 52
    sget-object v0, Landroid/graphics/Typeface;->SANS_SERIF:Landroid/graphics/Typeface;

    .line 58
    :cond_0
    :goto_0
    const/4 v3, 0x0

    .line 59
    .local v3, style:I
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getStyle()I

    move-result v5

    and-int/lit8 v5, v5, 0x0

    if-eqz v5, :cond_1

    .line 60
    or-int/lit8 v3, v3, 0x0

    .line 62
    :cond_1
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getStyle()I

    move-result v5

    and-int/lit8 v5, v5, 0x1

    if-eqz v5, :cond_2

    .line 63
    or-int/lit8 v3, v3, 0x1

    .line 65
    :cond_2
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getStyle()I

    move-result v5

    and-int/lit8 v5, v5, 0x2

    if-eqz v5, :cond_3

    .line 66
    or-int/lit8 v3, v3, 0x2

    .line 68
    :cond_3
    const/4 v4, 0x0

    .line 69
    .local v4, underlined:Z
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getStyle()I

    move-result v5

    and-int/lit8 v5, v5, 0x4

    if-eqz v5, :cond_4

    .line 70
    const/4 v4, 0x1

    .line 72
    :cond_4
    const/4 v2, 0x0

    .line 73
    .local v2, size:I
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getSize()I

    move-result v5

    const/16 v6, 0x8

    if-ne v5, v6, :cond_9

    .line 74
    sget v2, Lorg/microemu/android/device/AndroidFontManager;->SIZE_SMALL:I

    .line 80
    :cond_5
    :goto_1
    new-instance v1, Lorg/microemu/android/device/AndroidFont;

    .end local v1           #result:Lorg/microemu/android/device/AndroidFont;
    invoke-static {v0, v3}, Landroid/graphics/Typeface;->create(Landroid/graphics/Typeface;I)Landroid/graphics/Typeface;

    move-result-object v5

    invoke-direct {v1, v5, v2, v4}, Lorg/microemu/android/device/AndroidFont;-><init>(Landroid/graphics/Typeface;IZ)V

    .line 81
    .restart local v1       #result:Lorg/microemu/android/device/AndroidFont;
    sget-object v5, Lorg/microemu/android/device/AndroidFontManager;->fonts:Ljava/util/HashMap;

    invoke-virtual {v5, p0, v1}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 84
    .end local v0           #family:Landroid/graphics/Typeface;
    .end local v3           #style:I
    .end local v4           #underlined:Z
    .end local v2           #size:I
    :cond_6
    return-object v1

    .line 53
    .restart local v0       #family:Landroid/graphics/Typeface;
    :cond_7
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getFace()I

    move-result v5

    const/16 v6, 0x20

    if-ne v5, v6, :cond_8

    .line 54
    sget-object v0, Landroid/graphics/Typeface;->MONOSPACE:Landroid/graphics/Typeface;

    .restart local v0       #family:Landroid/graphics/Typeface;
    goto :goto_0

    .line 55
    :cond_8
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getFace()I

    move-result v5

    const/16 v6, 0x40

    if-ne v5, v6, :cond_0

    .line 56
    sget-object v0, Landroid/graphics/Typeface;->SANS_SERIF:Landroid/graphics/Typeface;

    .restart local v0       #family:Landroid/graphics/Typeface;
    goto :goto_0

    .line 75
    .restart local v2       #size:I
    .restart local v3       #style:I
    .restart local v4       #underlined:Z
    :cond_9
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getSize()I

    move-result v5

    if-nez v5, :cond_a

    .line 76
    sget v2, Lorg/microemu/android/device/AndroidFontManager;->SIZE_MEDIUM:I

    .restart local v2       #size:I
    goto :goto_1

    .line 77
    :cond_a
    invoke-virtual {p0}, Ljavax/microedition/lcdui/Font;->getSize()I

    move-result v5

    const/16 v6, 0x10

    if-ne v5, v6, :cond_5

    .line 78
    sget v2, Lorg/microemu/android/device/AndroidFontManager;->SIZE_LARGE:I

    .restart local v2       #size:I
    goto :goto_1
.end method


# virtual methods
.method public charWidth(Ljavax/microedition/lcdui/Font;C)I
    .locals 1
    .parameter "f"
    .parameter "ch"

    .prologue
    .line 96
    invoke-static {p1}, Lorg/microemu/android/device/AndroidFontManager;->getFont(Ljavax/microedition/lcdui/Font;)Lorg/microemu/android/device/AndroidFont;

    move-result-object v0

    invoke-virtual {v0, p2}, Lorg/microemu/android/device/AndroidFont;->charWidth(C)I

    move-result v0

    return v0
.end method

.method public charsWidth(Ljavax/microedition/lcdui/Font;[CII)I
    .locals 1
    .parameter "f"
    .parameter "ch"
    .parameter "offset"
    .parameter "length"

    .prologue
    .line 102
    invoke-static {p1}, Lorg/microemu/android/device/AndroidFontManager;->getFont(Ljavax/microedition/lcdui/Font;)Lorg/microemu/android/device/AndroidFont;

    move-result-object v0

    invoke-virtual {v0, p2, p3, p4}, Lorg/microemu/android/device/AndroidFont;->charsWidth([CII)I

    move-result v0

    return v0
.end method

.method public getBaselinePosition(Ljavax/microedition/lcdui/Font;)I
    .locals 1
    .parameter "f"

    .prologue
    .line 107
    invoke-static {p1}, Lorg/microemu/android/device/AndroidFontManager;->getFont(Ljavax/microedition/lcdui/Font;)Lorg/microemu/android/device/AndroidFont;

    move-result-object v0

    invoke-virtual {v0}, Lorg/microemu/android/device/AndroidFont;->getBaselinePosition()I

    move-result v0

    return v0
.end method

.method public getHeight(Ljavax/microedition/lcdui/Font;)I
    .locals 1
    .parameter "f"

    .prologue
    .line 113
    invoke-static {p1}, Lorg/microemu/android/device/AndroidFontManager;->getFont(Ljavax/microedition/lcdui/Font;)Lorg/microemu/android/device/AndroidFont;

    move-result-object v0

    invoke-virtual {v0}, Lorg/microemu/android/device/AndroidFont;->getHeight()I

    move-result v0

    return v0
.end method

.method public init()V
    .locals 1

    .prologue
    .line 90
    sget-object v0, Lorg/microemu/android/device/AndroidFontManager;->fonts:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->clear()V

    .line 91
    return-void
.end method

.method public stringWidth(Ljavax/microedition/lcdui/Font;Ljava/lang/String;)I
    .locals 1
    .parameter "f"
    .parameter "str"

    .prologue
    .line 119
    invoke-static {p1}, Lorg/microemu/android/device/AndroidFontManager;->getFont(Ljavax/microedition/lcdui/Font;)Lorg/microemu/android/device/AndroidFont;

    move-result-object v0

    invoke-virtual {v0, p2}, Lorg/microemu/android/device/AndroidFont;->stringWidth(Ljava/lang/String;)I

    move-result v0

    return v0
.end method
